package com.asset.salesforce.dao;

import java.util.ArrayList;
import java.util.List;

import com.asset.salesforce.domain.InvoiceSku;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

@Repository
public class InvoiceSkuDaoImpl extends BasicDaoImpl<InvoiceSku> {
	public List<InvoiceSku> getInvoiceSkusByInvoice(Integer id){
		Session session =sessionFactory.getCurrentSession();
		Query query = session.createQuery("select sku from InvoiceSku sku, InvoiceItem itm where itm.invoice.id= :id and itm.invoiceItemParent.id = sku.id");
		query.setParameter("id", id);
		List<InvoiceSku> invoiceSkusList = new ArrayList<InvoiceSku>();
		invoiceSkusList = query.list();
		return invoiceSkusList;
	}
}
